#include"add.h"

int main()
{
    key_t key=getkey();
    cout<<"生成的key = "<<key<<endl;
    
    //创建消息队列(和共享内存一样)
    int msqid = msgget(key,IPC_CREAT|IPC_EXCL);
    cout<<"msqid = "<<msqid<<endl;
    if (msqid == -1)                                            
    {
        cout << "errno = " << errno << ",strerrno = " << strerror(errno) << endl;
        exit(1);
    }

    //获取消息队列里的内容
    struct msqid_ds ds;
    msgctl(msqid,IPC_STAT,&ds);
    cout<<"消息队列中的key = "<<ToHex(ds.msg_perm.__key)<<endl;
    sleep(10);
    //删除消息队列
    msgctl(msqid,IPC_RMID,nullptr);
    cout<<"删除消息队列..."<<endl;
    

}